/*
 * Jamus
 * Copyright (C) 2010 Jamus Team
 *
 * Jamus is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jamus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jamus.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __FRONTEND_INTERFACE
#define __FRONTEND_INTERFACE

#include <boost/property_tree/ptree.hpp>

#include "../backend/Plugin.h"

/* interface for the frontend plugins */

namespace frontend {

class Plugin
{
public:
	Plugin(backend::Plugin& backend) : backend(backend) {}
	virtual ~Plugin() {};

	/**
	 * Starts the front-end. Usually you should call the run method of each
	 * front-end in its own thread.
	 */
	virtual void run() = 0;

	/**
	 * Tells the front-end to terminate. Calls to run() should return
	 * afterwards.
	 */
	virtual void cancel() = 0;

protected:
	backend::Plugin& backend;
};

typedef Plugin* create_p(const boost::property_tree::ptree& config, backend::Plugin& backend);
typedef void destroy_p(Plugin* t);

} // namespace frontend

#endif
